home *** CD-ROM | disk | FTP | other *** search
/ Packard Bell - Multimedia…D & Packard Bell Library / Packard Bell Master CD.iso / diskimag / pnp / disk1.img / SETUP.MST < prev    next >
Text File  |  1995-02-09  |  15KB  |  532 lines

  1. '******************************************************************************
  2. '**  Auto-configuration software setup script
  3. '******************************************************************************
  4.  
  5. ''$DEFINE DUMPLIST
  6. ''$DEFINE NOCOPY
  7.  
  8. '$INCLUDE 'setupapi.inc'
  9. '$INCLUDE 'msdetect.inc'
  10.  
  11. '' WINDOWS SYSTEM ID's
  12. CONST IDYES                = 6
  13. CONST IDNO                = 7
  14.  
  15. '' Message Box ID's
  16.  
  17. CONST MB_YESNO             = 4
  18. CONST MB_ICONQUSTION     = 32
  19.  
  20. '' Dialog ID's
  21. CONST WELCOME       = 100
  22. CONST DONTUSE       = 150
  23. CONST ASKQUIT       = 200
  24. CONST DESTPATH      = 300
  25. CONST EXITFAILURE   = 400
  26. CONST EXITQUIT      = 600
  27. CONST EXITSUCCESS   = 700
  28. CONST OPTIONS       = 800
  29. CONST APPHELP       = 900
  30. CONST TOOBIG        = 6300
  31. CONST BADPATH       = 6400
  32.  
  33. CONST LOGO = 1      '' bitmap ID - identifies bitmap in DIALOGS.RC
  34.  
  35. '' GLOBAL VARAIBLES
  36. GLOBAL DEST$        '' destination directory
  37. GLOBAL YESNO%
  38. GLOBAL szESCD%
  39.  
  40. '' function declarations
  41. DECLARE SUB Install
  42. DECLARE SUB AddDosDriver( szFile$, szDevText$ )
  43. DECLARE SUB CommentOutVxD( szVxD$, szWindowsDir$ )
  44. DECLARE FUNCTION MakePath( szDir$, szFile$ ) AS STRING
  45. DECLARE SUB AddBuffers
  46.  
  47.  
  48. ''String Defs.
  49. YESNOMSG$ = "An ESCD.RF file has been detected.  Do you want to overwrite it ?"
  50.  
  51.  
  52. INIT:
  53.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  54.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  55.  
  56.     '' put opening bitmap on the screen
  57.     SetBitmap CUIDLL$, LOGO
  58.     SetTitle "Plug and Play Kit for Windows"
  59.  
  60.     '' figure out where the .INF file is and read it
  61.     szInf$ = GetSymbolValue( "STF_SRCINFPATH" )
  62.     IF szInf$ = "" THEN
  63.         szInf$ = GetSymbolValue( "STF_CWDDIR" ) + "SETUP.INF"
  64.     END IF
  65.     ReadInfFile szInf$
  66.  
  67.     '' identify the default Plug and Play installation directory
  68.     DEST$ = "C:\PLUGPLAY"
  69.  
  70.  
  71. WELCOME:
  72.     SetAbout "Plug and Play Kit for Windows", "Copyright 1993, 1994 Intel Corporation, All Rights Reserved"
  73.     sz$ = UIStartDlg( CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$ )
  74.     IF sz$ = "CONTINUE" THEN
  75.         UIPop 1
  76.     ELSE
  77.         GOSUB ASKQUIT
  78.         GOTO WELCOME
  79.     END IF
  80.  
  81. DONTUSE:
  82.     sz$ = UIStartDlg( CUIDLL$, DONTUSE, "FInfoDlgProc", APPHELP, HELPPROC$ )
  83.     IF sz$ = "CONTINUE" THEN
  84.         UIPop 1
  85.     ELSE
  86.         GOSUB ASKQUIT
  87.         GOTO WELCOME
  88.     END IF
  89.  
  90. GETPATH:
  91.     SetSymbolValue "EditTextIn", DEST$
  92.     SetSymbolValue "EditFocus", "END"
  93. GETPATHL1:
  94.     '' present window for user to select Plug and Play install directory
  95.     sz$ = UIStartDlg( CUIDLL$, DESTPATH, "FEditDlgProc", 0, "" )
  96.     DEST$ = GetSymbolValue( "EditTextOut" )
  97.  
  98.     IF sz$ = "CONTINUE" THEN
  99.         IF IsDirWritable( DEST$ ) = 0 THEN
  100.             GOSUB BADPATH
  101.             GOTO GETPATHL1
  102.         END IF
  103.         UIPop 1
  104.     ELSEIF sz$ = "REACTIVATE" THEN
  105.         GOTO GETPATHL1
  106.     ELSEIF sz$ = "BACK" THEN
  107.         UIPop 1
  108.         GOTO WELCOME
  109.     ELSE
  110.         GOSUB ASKQUIT
  111.         GOTO GETPATH
  112.     END IF
  113.  
  114.     '' Check to see if there is enough space on the target disk.        
  115. CKSIZE:
  116.     DRIVE$ = MID$(DEST$,1,1)
  117.     FREE& = GetFreeSpaceForDrive(drive$)
  118.     IF FREE < 2500000 THEN 
  119.     GOTO TOOBIG
  120.  
  121. EndIf
  122.  
  123. ISESCD:
  124.     szESCD% = DoesFileExist("C:\ESCD.RF", fenExists)
  125.     If szESCD% = 1 Then
  126.         yesno% = DoMsgBox( YESNOMSG$, "ESCD.RF FOUND", MB_YESNO+MB_ICONQUESTION)
  127.     EndIF
  128.  
  129.     If ( szESCD% =1 and yesno% = IDYES) THEN
  130.             BackupFile "C:\ESCD.RF", "ESCD.BAK" 
  131.     EndIf
  132.         
  133.     '' We have an installation directory and know where the Windows directory
  134.     '' and the Windows SYSTEM directory are.  Now call the Install subroutine
  135.     '' to do the real work
  136.  
  137.     Install
  138.  
  139.  
  140. QUIT:
  141.     ON ERROR GOTO ERRQUIT
  142.  
  143.     IF ERR = 0 THEN
  144.         dlg% = EXITSUCCESS
  145.     ELSEIF ERR = STFQUIT THEN
  146.         dlg% = EXITQUIT
  147.     ELSE
  148.         dlg% = EXITFAILURE
  149.     END IF
  150. QUITL1:
  151.     sz$ = UIStartDlg( CUIDLL$, dlg%, "FInfo0DlgProc", 0, "" )
  152.     IF sz$ = "REACTIVATE" THEN
  153.         GOTO QUITL1
  154.     END IF
  155.     UIPop 1
  156.  
  157.     END
  158.  
  159.  
  160. ERRQUIT:
  161.     i% = DoMsgBox( "Software installation is incomplete", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND )
  162.     END
  163.  
  164.  
  165. BADPATH:
  166.     sz$ = UIStartDlg( CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "" )
  167.     IF sz$ = "REACTIVATE" THEN
  168.         GOTO BADPATH
  169.     END IF
  170.     UIPop 1
  171.     RETURN
  172.  
  173.  
  174. ASKQUIT:
  175.     sz$ = UIStartDlg( CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "" )
  176.  
  177.     IF sz$ = "EXIT" THEN
  178.         UIPopAll
  179.         ERROR STFQUIT
  180.     ELSEIF sz$ = "REACTIVATE" THEN
  181.         GOTO ASKQUIT
  182.     ELSE
  183.         UIPop 1
  184.     END IF
  185.     RETURN
  186.  
  187. TOOBIG:
  188.     sz$ = UIStartDlg( CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "" )
  189.     IF sz$ = "REACTIVATE" THEN
  190.         GOTO TOOBIG
  191.     ELSEIF sz$ = "CONTINUE" THEN
  192.         UIPop 1
  193.         dlg% = EXITFAILURE
  194.         GOTO QUITL1
  195.     END IF
  196.     RETURN
  197.  
  198. '******************************************************************************
  199. '** subroutine:  Install
  200. '**
  201. '** Purpose:
  202. '**     Builds the copy list and performs all installation operations.
  203. '** Arguments:
  204. '**     none.
  205. '** Returns:
  206. '**     none.
  207. '******************************************************************************
  208. SUB Install STATIC
  209.  
  210.     SrcDir$ = GetSymbolValue( "STF_SRCDIR" )
  211.   
  212.  
  213.     '' create Plug and Play installation directory
  214.     ''
  215.     CreateDir DEST$, cmoVital
  216.  
  217.     '' create subdirectories for ICU, ICU\DB, and DRIVERS\DOS
  218.     ''
  219.     ICUdir$ = MakePath( DEST$, "ICU" )
  220.     CreateDir ICUdir$, cmoVital
  221.  
  222.     DBdir$ = MakePath( ICUdir$, "DB" )
  223.     CreateDir DBdir$, cmoVital
  224.  
  225.     CMdir$ = MakePath( DEST$, "DRIVERS" )
  226.     CreateDir CMdir$, cmoVital
  227.  
  228.     DCMdir$ = MakePath( CMdir$, "DOS" )
  229.     CreateDir DCMdir$, cmoVital
  230.  
  231.     '' locate Windows installation directory and SYSTEM subdirectory
  232.     ''
  233.     WinDir$ = GetWindowsDir()
  234.     WinSys$ = GetWindowsSysDir()
  235.     SysIni$ = WinDir$ + "SYSTEM.INI"
  236.     SysBak$ = MakePath( DEST$, "SYSTEM.BAK" )
  237.  
  238.     '' Remove old readme files from previous installations
  239.     RemoveFile ICUdir$ + "\README.WIN", cmoForce
  240.     RemoveFile ICUdir$ + "\README.DOS", cmoForce
  241.     RemoveFile ICUdir$ + "\README.CM", cmoForce
  242.     RemoveFile DEST$ + "\README.CM", cmoForce
  243.     RemoveFile DEST$ + "\README.DDK", cmoForce
  244.  
  245.     '' Remove !dec2030,2040,2050 cfg files
  246.     RemoveFile DBdir$ + "\!dec2030.cfg", cmoForce 
  247.     RemoveFile DBdir$ + "\!dec2040.cfg", cmoForce 
  248.     RemoveFile DBdir$ + "\!dec2050.cfg", cmoForce 
  249.  
  250.     '' create file copy list from sections in .INF file
  251.     ''
  252.     AddSectionFilesToCopyList "ICU_readme",      SrcDir$, DEST$
  253.     AddSectionFilesToCopyList "ICU_binaries",    SrcDir$, ICUdir$
  254.     AddSectionFilesToCopyList "ICU_database",    SrcDir$, DBdir$
  255.     AddSectionFilesToCopyList "ESCD_image",      SrcDir$, DCMdir$
  256.     AddSectionFilesToCopyList "DOS_CM_binaries", SrcDir$, DCMdir$
  257.     AddSectionFilesToCopyList "Win_CM_binaries", SrcDir$, WinSys$
  258.     AddSectionFilesToCopyList "ICU_winsys",      SrcDir$, WinSys$
  259.     If ( (szESCD% =1 AND YESNO% = IDYES) OR (szESCD% = 0)) THEN
  260.         AddSectionFilesToCopyList "ESCD_image",      SrcDir$, "C:\"
  261.     EndIf
  262.     '$IFDEF DUMPLIST
  263.     DumpCopyList "C:\~WINICU.LST"
  264.     '$ENDIF
  265.  
  266.     '$IFNDEF NOCOPY
  267.     '' copy files to appropriate locations
  268.      CopyFilesInCopyList
  269.  
  270.     '' create WINICU.INI in the Windows directory with the installation values
  271.     ''   [Pathnames]
  272.     ''   ICUDir=C:\PLUGPLAY\ICU
  273.     ''   Database=DB
  274.     ''   Indexfile=ICU.NDX
  275.     ''   Imagefile=SYSTEM.IMG
  276.     ''
  277.     '' note that Setup does not create the [Settings] section or any keys in it;
  278.     '' WinICU creates/updates these at runtime
  279.     ''
  280.     ICUini$ = WinDir$ + "WINICU.INI"
  281.     RemoveIniKey ICUini$, "Settings", "HideUnchangeableCards", cmoNone
  282.     CreateIniKeyValue ICUini$, "Pathnames", "ICUDir",    ICUdir$,      cmoOverwrite
  283.     CreateIniKeyValue ICUini$, "Pathnames", "Database",  "DB",         cmoOverwrite
  284.     CreateIniKeyValue ICUini$, "Pathnames", "Indexfile", "ICU.NDX",    cmoOverwrite
  285.     CreateIniKeyValue ICUini$, "Pathnames", "Imagefile", "SYSTEM.IMG", cmoOverwrite
  286.     '$ENDIF '' NOCOPY
  287.  
  288.     '' add a DEVICE= line for the DOS CM driver in CONFIG.SYS
  289.     ''
  290.     szDevText$ = MakePath( DCMdir$, "DWCFGMG.SYS" )
  291.  
  292.     AddBuffers
  293.     AddDosDriver "DWCFGMG.SYS", szDevText$
  294.  
  295.     '$IFNDEF NOCOPY
  296.     '' check for a key in WIN.INI - if there is none, create one and add the CM
  297.     '' drivers to SYSTEM.INI
  298.     ''
  299.     sz$ = GetIniKeyString( "WIN.INI", "ConfigMgr", "Installed" )
  300.     IF sz$ = "yes" THEN
  301.         GOTO VXDINSTALLED
  302.     END IF
  303.     CreateIniKeyValue "WIN.INI", "ConfigMgr", "Installed", "yes", cmoNone
  304.  
  305.     '' backup SYSTEM.INI, then add device entries for CA and CM in [386Enh] section
  306.     ''
  307.     CopyFile SysIni$, SysBak$, cmoOverwrite, 0
  308.     CreateSysIniKeyValue SysIni$, "386Enh", "device", "VCAD.386", cmoVital
  309.     CreateSysIniKeyValue SysIni$, "386Enh", "device", "VCMD.386", cmoVital
  310.     CreateSysIniKeyValue SysIni$, "386Enh", "device", "PCCARDRM.386", cmoVital
  311.  
  312.     CommentOutVxD "PCCARDRM.386", WinDir$
  313.  
  314. VXDINSTALLED:
  315.  
  316.     '' create Plug and Play program group in Program Manager - contains ICU
  317.     '' executable and README.TXT
  318.     ''
  319.     CreateProgmanGroup "Plug and Play", "", cmoNone
  320.     ShowProgmanGroup   "Plug and Play", 1,  cmoNone
  321.     CreateProgmanItem  "Plug and Play", "Intel ISA Configuration Utility", MakePath( ICUdir$,"WINICU.EXE" ), "", cmoOverwrite
  322.     CreateProgmanItem  "Plug and Play", "Release Notes", "NOTEPAD.EXE "+MakePath( DEST$,"README.TXT" ), "", cmoOverwrite
  323.     CreateProgmanItem  "Plug and Play", "ICU User's Guide", "WINHELP.EXE "+MakePath( ICUdir$,"ICUUG.HLP" ), "", cmoOverwrite
  324.     '$ENDIF '' NOCOPY
  325.  
  326.  
  327. MKNDX:
  328.     CHDRIVE DEST$
  329.     CHDIR DEST$ + "\ICU\DB"
  330.     SHELL DEST$ + "\ICU\DB\CFGNDX.EXE"
  331.     CHDRIVE szInf$
  332.  
  333. END SUB
  334.  
  335.  
  336. '******************************************************************************
  337. '**
  338. '** subroutine:  AddDosDriver
  339. '**
  340. '** Purpose:   Adds a DEVICE=<file> entry to CONFIG.SYS for the specified file.
  341. '**            An existing line in CONFIG.SYS with the same filename will be
  342. '**            deleted.  If CONFIG.SYS doesn't exist, a new one is created.
  343. '**            An existing CONFIG.SYS is renamed CONFIG.BAK.
  344. '**
  345. '** Arguments:
  346. '**     szFile$ - filename of driver
  347. '**     szDevText$ - driver pathname and invocation options, e.g.,
  348. '**               "C:\PLUGPLAY\DRIVERS\DOS\DWCFGMG.SYS"
  349. '**
  350. '******************************************************************************
  351. SUB AddDosDriver( szFile$, szDevText$ ) STATIC
  352.  
  353. '' read CONFIG.SYS and write CONFIG.NEW line by line.  delete any line with a
  354. '' matching driver name
  355. ''
  356.     OPEN "C:\CONFIG.NEW" FOR OUTPUT AS #2
  357.     PRINT #2, "DEVICE="; szDevText$
  358.     IF NOT EXISTS( "C:\CONFIG.SYS" ) THEN
  359.         cfg% = 0
  360.         GOTO NOCFGSYS
  361.     END IF
  362.  
  363.     cfg% = 1
  364.     OPEN "C:\CONFIG.SYS" FOR INPUT  AS #1
  365.  
  366.     WHILE NOT( EOF( 1 ) )
  367.         LINE INPUT #1, szLine$
  368.         szTest$ = UCASE$( szLine$ )
  369.         pos% = INSTR( szTest$, szFile$ )
  370.         IF pos% = 0 THEN
  371.             PRINT #2, szLine$
  372.         END IF
  373.     WEND
  374.  
  375. NOCFGSYS:
  376.     CLOSE #2
  377.  
  378.     IF cfg% = 1 THEN
  379.         CLOSE #1
  380.         IF EXISTS( "C:\CONFIG.BAK" ) THEN
  381.             KILL "C:\CONFIG.BAK"
  382.         END IF
  383.         NAME "C:\CONFIG.SYS" AS "C:\CONFIG.BAK"
  384.     END IF
  385.     NAME "C:\CONFIG.NEW" AS "C:\CONFIG.SYS"
  386.  
  387. END SUB
  388.  
  389. '******************************************************************************
  390. '**
  391. '** subroutine:  CommentOutVxD
  392. '**
  393. '** Purpose:   Puts a comment character in front of a VxD invocation in 
  394. '**            the windows\system.ini file.
  395. '**
  396. '** Arguments:
  397. '**     szVxD$ - name of VxD
  398. '**     szWindowsDir$ - The windows directory: e.g. c:\windows\
  399. '**
  400. '******************************************************************************
  401. SUB CommentOutVxD ( szVxD$, szWindowsDir$ ) STATIC
  402.  
  403. '' read system.ini and write system.new line by line.  
  404. ''
  405.     szCurDir$=CURDIR$
  406.     CHDRIVE szWindowsDir$
  407.     szWinDirNoSlash$=MID$ (szWindowsDir,1,LEN(szWindowsDir)-1)
  408.     CHDIR szWinDirNoSlash$
  409.     OPEN szWindowsDir$ + "SYSINI.NEW" FOR OUTPUT AS #2
  410.     OPEN szWindowsDir$ + "SYSTEM.INI" FOR INPUT  AS #1
  411.  
  412.     WHILE NOT( EOF( 1 ) )
  413.         LINE INPUT #1, szLine$
  414.         szTest$ = UCASE$( szLine$ )
  415.         pos% = INSTR( szTest$, szVxD$ )
  416.         IF pos% = 0 THEN
  417.             PRINT #2, szLine$
  418.             ELSE 
  419.                 PRINT #2, ";"; szLine$
  420.         END IF
  421.     WEND
  422.  
  423.  
  424.     CLOSE #2
  425.     CLOSE #1
  426.         IF EXISTS( "SYSINI.BAK" ) THEN
  427.             KILL "SYSINI.BAK"
  428.         END IF
  429.         NAME "SYSTEM.INI" AS "SYSINI.BAK"
  430.     NAME "SYSINI.NEW" AS "SYSTEM.INI"
  431.  
  432.     CHDRIVE szCurDir$
  433.     CHDIR szCurDir$
  434. END SUB
  435.  
  436. '******************************************************************************
  437. '**
  438. '** function:  MakePath
  439. '**
  440. '** Purpose:   Appends a file name to the end of a directory path, inserting a
  441. '**            backslash character as needed.
  442. '** Arguments:
  443. '**     szDir$  - full directory path (with optional ending "\")
  444. '**     szFile$ - filename to append to directory
  445. '** Returns:
  446. '**     Resulting fully qualified path name.
  447. '******************************************************************************
  448. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  449.  
  450.     IF szDir$ = "" THEN
  451.         MakePath = szFile$
  452.     ELSEIF szFile$ = "" THEN
  453.         MakePath = szDir$
  454.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  455.         MakePath = szDir$ + szFile$
  456.     ELSE
  457.         MakePath = szDir$ + "\" + szFile$
  458.     END IF
  459.  
  460. END FUNCTION
  461.  
  462.  
  463. '******************************************************************************
  464. '**
  465. '** subroutine:  AddBuffers
  466. '**
  467. '** Purpose:   Checks to see if the entry in CONFIG.SYS for BUFFERS=<Buffer #) 
  468. '**            ig greater or equal to 20. If not BUFFERS will be set to 20. 
  469. '**            If CONFIG.SYS doesn't exist, a new one is created.
  470. '**            An existing CONFIG.SYS is renamed CONFIG.BAK.
  471. '**
  472. '** Arguments:
  473. '**     szBUF$ - filename of driver
  474. '**                                                               
  475. '**                                                           
  476. '**
  477. '******************************************************************************
  478. SUB AddBuffers STATIC
  479.  
  480. '' read CONFIG.SYS and write CONFIG.NEW line by line.
  481. '' 
  482. ''
  483.     DIDBUF = 0
  484.     OPEN "C:\CONFIG.NEW" FOR OUTPUT AS #2
  485.     IF NOT EXISTS( "C:\CONFIG.SYS" ) THEN
  486.         cfg% = 0
  487.         GOTO WRITENEWCFG
  488.     END IF
  489.  
  490.     cfg% = 1
  491.     OPEN "C:\CONFIG.SYS" FOR INPUT  AS #1
  492.  
  493.     WHILE NOT( EOF( 1 ) )
  494.         LINE INPUT #1, szLine$
  495.         szTest$ = UCASE$( szLine$ )
  496.         pos% = INSTR( szTest$, "BUFFERS=")
  497.         IF pos% = 0 THEN
  498.             PRINT #2, szLine$
  499.         ELSE
  500.             szBUFFS$ = szLine$
  501.              BUF% = VAL(MID$ (szTEST$, 9, 2))
  502. IF BUF >= 20 AND DIDBUF = 0 then
  503.             PRINT #2, szBUFFS$
  504.             DIDBUF = 1
  505.         ELSE
  506.             PRINT #2, "BUFFERS=20"
  507.             DIDBUF = 1
  508.         END IF
  509.  
  510.         END IF
  511.  
  512.         
  513.     WEND
  514.  
  515.         
  516. WRITENEWCFG:
  517.     IF cfg% = 0 THEN
  518.         PRINT #2, "BUFFERS=20"
  519.     End IF
  520.  
  521.     CLOSE #2
  522.     IF cfg% = 1 THEN
  523.         CLOSE #1
  524.         IF EXISTS( "C:\CONFIG.BAK" ) THEN
  525.             KILL "C:\CONFIG.BAK"
  526.         END IF
  527.         NAME "C:\CONFIG.SYS" AS "C:\CONFIG.BAK"
  528.     END IF
  529.     NAME "C:\CONFIG.NEW" AS "C:\CONFIG.SYS"
  530.  
  531. END SUB
  532.